package com.csd.controller;

import com.csd.dto.ActionResult;
import com.csd.po.Car;
import com.csd.po.City;
import com.csd.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: CeSuDi_SSM
 * @description:
 * @author: 苏蕊
 * @create: 2020-12-22 18:30
 */
@Controller
public class CityController {
    @Autowired
    private CityService cityService;

    /**
     * 短期自驾
     * @param pid
     * @return
     */
    @RequestMapping(value="/getCities",method= RequestMethod.POST)
    @ResponseBody
    public ActionResult findCityByPid(int pid){
        List<City> cities = cityService.selectCitiesByPid(pid);
        System.out.println(cities);
        ActionResult result = new ActionResult(200, null, cities);
        return result;
    }


    /**
     * 取车地址和还车地址
     * @param getid
     * @return
     */

    @RequestMapping("/getcityByGetid")
    @ResponseBody
    public City getcityByGetid(Integer getid){

        City city = cityService.getcityByGetid(getid);
        return city;
    }


}
